import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { SGuildStructureInfo } from "../../../../../Message/Game/SGuildStructureInfo";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { GuildStructureConfig } from "../../../resource/GuildStructureConfig";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { GuildEventName } from "../GuildEventName";
//class BuildingItemRender
    
    export  class BuildingItemRender extends CellRenderer
    {
        constructor()
        {
            super();
            this.initStyles();
            this.init();
            this.mouseChildren = false;
            this.buttonMode = true;
            this.useHandCursor = true;
            return;
        }

        /* internal  */initStyles(): void
        {
            this.setStyle("downSkin", GlobalClass.getBitmap(ImagesConst.Friend_over));
            this.setStyle("overSkin", GlobalClass.getBitmap(ImagesConst.Friend_over));
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", GlobalClass.getBitmap(ImagesConst.Friend_over));
            this.setStyle("selectedOverSkin", GlobalClass.getBitmap(ImagesConst.Friend_over));
            this.setStyle("selectedUpSkin", GlobalClass.getBitmap(ImagesConst.Friend_over));
            return;
        }

        /* internal  */init(): void
        {
            var loc1=0;
            loc1 = 11661567;
            graphics.beginFill(16777215, 0);
            graphics.drawRect(0, 0, 125, 25);
            graphics.endFill();
            this._nameText = new Object /* flash.text.TextField */();
            this._nameText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._nameText.textColor = loc1;
            this._nameText.x = 10;
            this._nameText.mouseEnabled = false;
            this.addChild(this._nameText);
            this._levelText = new Object /* flash.text.TextField */();
            this._levelText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._levelText.textColor = loc1;
            this._nameText.mouseEnabled = false;
            this._levelText.x = 75;
            this.addChild(this._levelText);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            this._structureInfo = arg1 as SGuildStructureInfo;
            if (this._structureInfo) 
            {
                this._nameText.text = GameDefConfig.instance.getGuildBuildingName(this._structureInfo.type.__value);
                this._levelText.text = "Lv " + this._structureInfo.level + "/" + GuildStructureConfig.instance.getMaxLevelByType(this._structureInfo.type.__value);
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                Dispatcher.dispatchEvent(new DataEvent(GuildEventName.SelectedBuilding, this._structureInfo));
            }
            return;
        }

        /* internal */ /* var */_nameText: Object /* flash.text.TextField */;

        /* internal */ /* var */_levelText: Object /* flash.text.TextField */;

        /* internal */ /* var */_structureInfo: SGuildStructureInfo;
    }
